ImageMaker = {}

function ImageMaker:make(key, width, height, shader)
    if ResourceSystem:hasImage(key) then
        return
    end
    local canvas = GetTempCanvasN2(width, height)

    love.graphics.setShader(shader)
    love.graphics.setBlendMode("replace", "premultiplied")
    love.graphics.setCanvas(canvas)
    love.graphics.rectangle("fill", 0, 0, width, height)
    love.graphics.setShader()
    love.graphics.setCanvas()
    love.graphics.setBlendMode("alpha")

    local canvasData = canvas:newImageData()
    local imgData = love.image.newImageData(width, height)
    imgData:mapPixel(function (x, y, r, g, b, a)
        local rr, gg, bb, aa = canvasData:getPixel(x, y)
        return rr, gg, bb, aa
    end)
    ResourceSystem:setImageData(key, imgData)
    local image = love.graphics.newImage(imgData)
    ResourceSystem:setImage(key, image)
end